﻿@{
    ViewBag.Title = "没想好";
    var F = Html.F();
}

@section head {


}

@{
    PanelExtension doLayout( GridExtension grid)
    {
        PanelExtension p = new PanelExtension(new Panel()
        {
            IsViewPort = true,
            Layout = LayoutType.VBox,
        });
        grid.BoxFlex(1);
        p.NoBorderAndHeader();
        p.Items(grid);
        return p;
    }
}

@section body {
    @(
    doLayout(
        F.Grid().ID("Grid1").DefaultAttr(new { PageItems=false })
        .ShowHeader(true).Title("表格")
        .EditWindow("Edit", "编辑",h:600)
        .Toolbars(
            F.Toolbar().Position(ToolbarPosition.Top).Items(
                 F.Button().CssClass("f-btn-Primary").BtnType(FineUIEx.BtnTypes.新增)
                 .OnClientClick("GridAdd_click('Grid1');"),
                 F.Button().CssClass("f-btn-Primary").BtnType(FineUIEx.BtnTypes.修改),
                 F.Button().CssClass("f-btn-Default").BtnType(FineUIEx.BtnTypes.删除)
                 .OnClientClick("GridDel_click('/Home','Grid1');"),
                 F.ToolbarFill(),
                 F.TextBox().EmptyText("输入检索项"),
                 F.Button().CssClass("f-btn-Primary").Text("查询").IconFont(IconFont.Search)
                )
            )
        .Columns(
            F.RowNumberField(),
            F.RenderField().HeaderText("姓名").DataField("Name").Width(100),
            F.RenderField().HeaderText("Back").DataField("Back").Hidden(true),
            F.RenderField().HeaderText("性别").DataField("Gender").FieldType(FieldType.Int).RendererFunction("renderGender").Width(100),
            F.RenderField().HeaderText("入学年份").DataField("EntranceYear").FieldType(FieldType.Int).Width(100),
            F.RenderField().HeaderText("入学日期").DataField("EntranceDate")
                .FieldType(FieldType.Date).Renderer(Renderer.Date).RendererArgument("yyyy-MM-dd").Width(150),
            F.RenderCheckField().HeaderText("是否在校").DataField("AtSchool").RenderAsStaticField(true).Width(100),
            F.RenderField().HeaderText("所学专业").DataField("Major").RendererFunctionEx("renderMajor").ExpandUnusedSpace(true).MinWidth(150),
            F.RenderField().HeaderText("分组").DataField("Group").RendererFunction("renderGroup").Width(100),
            F.RenderField().HeaderText("注册日期").DataField("LogTime").FieldType(FieldType.Date).Renderer(Renderer.Date).RendererArgument("yyyy-MM-dd").Width(100)
        )
        .DataSource(DataSourceUtil.GetDataTable())
    )
  )
}


@section script {
    <script src="~/res/js/grid.js"></script>
    <script>
        F.ready(function () {
        });

        function renderMajor(v, p, m) {
            //console.log(v);
            return `<span class="grid-tag">${v}</span>`;
        }
    </script>
}